<?php

namespace addons\tcfence;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Tcfence extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'tcfence',
                'title'   => '电子围栏',
                'icon'    => 'fa fa-anchor',
                'sublist' => [
                    [
                        'name'    => 'tcfence/areamanage',
                        'title'   => '区域管理',
                        'icon'    => 'fa fa-flag',
                        'sublist' => [
                            ['name' => 'tcfence/areamanage/import', 'title' => '导入'],
                            ['name' => 'tcfence/areamanage/index', 'title' => '查看'],
                            ['name' => 'tcfence/areamanage/add', 'title' => '添加'],
                            ['name' => 'tcfence/areamanage/edit', 'title' => '编辑'],
                            ['name' => 'tcfence/areamanage/del', 'title' => '删除'],
                            ['name' => 'tcfence/areamanage/mult', 'title' => '批量更新'],
                        ]
                    ],
                    [
                        'name'    => 'tcfence/fence',
                        'title'   => '围栏管理',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'tcfence/fence/import', 'title' => '导入'],
                            ['name' => 'tcfence/fence/index', 'title' => '查看'],
                            ['name' => 'tcfence/fence/add', 'title' => '添加'],
                            ['name' => 'tcfence/fence/edit', 'title' => '编辑'],
                            ['name' => 'tcfence/fence/del', 'title' => '删除'],
                            ['name' => 'tcfence/fence/mult', 'title' => '批量更新'],
                        ]
                    ],
                    [
                        'name'    => 'tcfence/fencedata',
                        'title'   => '围栏数据',
                        'icon'    => 'fa fa-database',
                        'sublist' => [
                            ['name' => 'tcfence/fencedata/import', 'title' => '导入'],
                            ['name' => 'tcfence/fencedata/index', 'title' => '查看'],
                            ['name' => 'tcfence/fencedata/add', 'title' => '添加'],
                            ['name' => 'tcfence/fencedata/edit', 'title' => '编辑'],
                            ['name' => 'tcfence/fencedata/del', 'title' => '删除'],
                            ['name' => 'tcfence/fencedata/mult', 'title' => '批量更新'],
                        ]
                    ]
                ]
            ]
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete('tcfence');
        return true;
    }

    /**
     * 插件启用方法
     */
    public function enable()
    {
        Menu::enable('tcfence');
        return true;
    }

    /**
     * 插件禁用方法
     */
    public function disable()
    {
        Menu::disable('tcfence');
        return true;
    }

}
